<template>
	<view class="content">
		<scroll-view scroll-y="true" class="content-it">
			<view class="img">
				<text class="img-txt">云南省第一人民医院</text>
				<view class="img-di">
					<image class="img-imgs" :src="weather.address_icon" mode="widthFix"></image>
					<text class="p1">{{weather.pname}}</text>
					<text class="p1">{{weather.secondaryname}}</text>
					<text class="p1">{{weather.name}}</text>
				</view>
				<view class="img-di">
					<image class="img-imgs" :src="weather.tigan_icon" mode="widthFix"></image>
					<text>体感温度</text>
					<text>{{weather.windLevel}}</text>
				</view>
				<view class="img-di">
					<image class="img-imgs" :src="weather.icon" mode="widthFix"></image>
					<text>紫外线强度</text>
					<text>1W/m</text>
				</view>
				<!-- 气温 -->
				<view class="qi">
					<view class="qi-qi1">
						<text>{{weather.realFeel}}</text>
						<text>{{weather.condition}}</text>
					</view>
					<view class="qi-qi1">
						<text>湿度</text>
						<text>{{weather.temp}}%</text>|
						<text>{{weather.windDir}}</text>
						<text>{{weather.uvi}}级</text>
					</view>
					<view class="qi-qi1">
						<text>{{weather.tips}}</text>
					</view>
				</view>
			</view>
			<!-- 列表 -->
			<view class="list">
				<view class="li" v-for="item,index in vaccine" :key="index" @tap="jump(index)">
					<image :src="item.image" mode="widthFix"></image>
					<view class="title">{{item.title}}</view>
				</view>
			</view>
			<!-- 预约挂号 -->
			<view class="yue">
				<view class="left">
					<view class="left-title">{{reserve[0].title}}</view>
					<view class="left-describe">{{reserve[0].describe}}</view>
					<image :src="reserve[0].image" mode="widthFix"></image>
				</view>
				<view class="rig">
					<view class="rig-title">{{reserve[1].title}}</view>
					<view class="rig-describe">{{reserve[1].describe}}</view>
					<image :src="reserve[1].image" mode="widthFix"></image>
				</view>
			</view>

			<!-- 热门挂号 -->
			<view class="gua">
				<view class="top">
					<text>热门挂号</text>
					<text>查看更多</text>
				</view>
				<view class="gua-list">
					<view class="list-it" v-for="(item,index) in popular" :key="index"
						:style="{background:item.background}">
						<text>{{item.title}}</text>
						<image :src="item.image" mode="widthFix"></image>
					</view>
				</view>
			</view>
			<!-- 健康自测 -->
			<view class="zide">
				健康自测
			</view>
			<!-- 抑郁测评专业版 -->
			<view class="yiyu">
				<view class="left">
					<text>{{self[0].name}}</text>
					<view class="describe">{{self[0].describe}}</view>
					<view class="msg">
						<text>{{self[0].number_of_people}}</text>
						<text class="t1">人测试过/</text>
						<text class="t1">{{self[0].question}}题/</text>
						<text class="t1">{{self[0].minute}}分钟</text>
					</view>
				</view>
				<image :src="self[0].image" mode="widthFix"></image>
			</view>
			<!-- 男性功能 -->
			<view class="nan">
				<view class="left">
					<view class="left-it">
						<text class="name">{{self[1].name}}</text>
						<view class="msg">
							<text class="t1">{{self[1].question}}题/</text>
							<text class="t1">{{self[1].minute}}分钟</text>
						</view>
						<text>{{self[1].number_of_people}}</text>
						<text class="t2">人测试过</text>
					</view>
					<image :src="self[1].image" mode="widthFix"></image>
				</view>
				<view class="rig">
					<view class="rig-it">
						<text class="name">{{self[2].name}}</text>
						<view class="msg">
							<text class="t1">{{self[2].question}}题/</text>
							<text class="t1">{{self[2].minute}}分钟</text>
						</view>
						<text>{{self[2].number_of_people}}</text>
						<text class="t2">人测试过</text>
					</view>
					<image :src="self[2].image" mode="widthFix"></image>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import api from '../../utils/request.js'
	export default {
		data() {
			return {
				vaccine: [],
				reserve: {},
				popular: [],
				self: {},
				params: {
					longitude: '',
					latitude: ''
				},
				weather: {},
				list: []
			}
		},
		async onLoad() {
			await this.getthan(),
				await this.getwen()

		},
		methods: {
			
			getthan() {
				api.get('/frontpage').then(res => {
					// console.log(res);
					this.vaccine = res.data[0].vaccine
					this.reserve = res.data[1].reserve
					this.popular = res.data[2].popular
					this.self = res.data[3].self_test
				})
			},
			getwen() {
				let tath = this
				uni.getLocation({
					type: 'wgs84',
					success: function(res) {
						let params = {
							longitude: res.longitude,
							latitude: res.latitude
						}
						api.get(`/weather?longitude=${params.longitude}&latitude=${params.latitude}`).then(
							res => {
								// console.log(res);
								tath.weather = res.data[0]
								// console.log(tath.weather);
							})
					}
				});
			},
			jump(i){
			  if(i==0){
				  uni.navigateTo({
				  	url:'/pages/xin/xin'
				  })
			  }
			}
		}
	}
</script>

<style lang="scss">
	.img {
		background-image: url('https://diancan-1252107261.cos.ap-chengdu.myqcloud.com/tianqi/tianqi-top.png');
		height: 700rpx;
		// background-color: pink;
		background-size: 100%, 100%;
		background-repeat: no-repeat;
		padding: 35rpx;
		color: #fff;
		position: relative;

		.qi {
			position: absolute;
			left: 50%;
			bottom: 10%;
			transform: translate(-50%, -10%);

			.qi-qi1 {
				text-align: center;

				text {
					display: inline-block;
					margin: 5rpx;
					margin-top: 10rpx;
				}
			}
		}

		.img-txt {
			font-size: 50rpx;
		}

		.img-di {
			display: flex;
			align-items: center;
			margin-top: 30rpx;

			.p1 {
				font-weight: 900;
			}

			.img-imgs {
				width: 50rpx;
				height: 50rpx;
				margin-right: 20rpx;
			}

			text {
				margin-right: 5rpx;
			}
		}
	}

	.nan {
		height: 250rpx;
		display: flex;
		margin: 10rpx;
		justify-content: space-between;

		.left {
			width: 49%;
			background-color: #fff;
			border-radius: 20rpx;
			padding: 10rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;

			image {
				width: 200rpx;
			}

			.left-it {
				width: 70%;

				.name {
					display: inline-block;
					width: 100vw;
				}

				.describe {
					margin: 10rpx 0;
					color: #c8cbce;
				}

				.t2 {
					font-size: 25rpx;
					color: #c8cbce;
					margin-left: 5rpx;
				}

				.msg {
					.t1 {
						font-size: 25rpx;
						color: #c8cbce;
						margin-left: 5rpx;
					}
				}
			}
		}

		.rig {
			width: 49%;
			background-color: #fff;
			border-radius: 20rpx;
			padding: 10rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;

			image {
				width: 200rpx;
			}

			.rig-it {
				width: 70%;

				.name {
					display: inline-block;
					width: 100vw;
				}

				.describe {
					margin: 10rpx 0;
					color: #c8cbce;
				}

				.t2 {
					font-size: 25rpx;
					color: #c8cbce;
					margin-left: 5rpx;
				}

				.msg {
					.t1 {
						font-size: 25rpx;
						color: #c8cbce;
						margin-left: 5rpx;
					}
				}
			}


		}
	}

	.yiyu {
		height: 280rpx;
		display: flex;
		align-items: center;
		padding: 10rpx;
		justify-content: space-between;
		background-color: #fff;

		image {
			width: 200rpx;
		}

		.describe {
			margin: 10rpx 0;
			color: #c8cbce;
		}

		.msg {
			.t1 {
				font-size: 25rpx;
				color: #c8cbce;
				margin-left: 5rpx;
			}
		}
	}

	.zide {
		line-height: 100rpx;
		padding: 10rpx;
		// background-color: pink;
		font-weight: 900;
	}

	.gua {
		padding: 10rpx;

		.top {
			display: flex;
			justify-content: space-between;
			font-weight: 900;
			align-items: center;
			height: 100rpx;
		}

		.gua-list {
			display: flex;
			flex-wrap: wrap;

			.list-it {
				width: 30%;
				height: 120rpx;
				border: 1rpx solid #ccc;
				border-radius: 10rpx;
				margin: 10rpx;
				display: flex;
				align-items: center;
				justify-content: space-around;
				// background-color: #d5e2ff;

				image {
					width: 50rpx;
					height: 50rpx;
				}
			}
		}
	}

	.content-it {
		height: calc(100vh - 100rpx);
		background-color: #f9f9f9;
	}

	.yue {
		height: 200rpx;
		display: flex;
		margin: 10rpx;
		justify-content: space-between;

		.left {
			width: 49%;
			background-image: linear-gradient(to left top, #6ea9ff, #d7dfff, );
			border-radius: 20rpx;
			padding: 25rpx;
			box-sizing: border-box;
			position: relative;

			.left-title {
				color: #3169ff;
				font-size: 45rpx;
			}

			.left-describe {
				color: #fff;
				font-size: 35rpx;
				margin-top: 10rpx;
			}

			image {
				position: absolute;
				right: 15rpx;
				bottom: 10rpx;
				width: 120rpx;
				height: 120rpx;
			}
		}

		.rig {
			width: 49%;
			background-image: linear-gradient(to left top, #ffc874, #ffdbb4, );
			border-radius: 20rpx;
			padding: 25rpx;
			box-sizing: border-box;
			position: relative;

			.rig-title {
				color: #dd650c;
				font-size: 45rpx;
			}

			.rig-describe {
				color: #fff;
				font-size: 35rpx;
				margin-top: 10rpx;
			}

			image {
				position: absolute;
				right: 15rpx;
				bottom: 10rpx;
				width: 120rpx;
				height: 120rpx;
			}
		}
	}

	.list {
		display: flex;
		height: 180rpx;
		// background-color: pink;
		align-items: center;

		.li {
			flex: 1;
			text-align: center;
			font-size: 30rpx;

			image {
				width: 50rpx;
				height: 50rpx;
				margin-top: 20rpx;
			}
		}
	}


	.content {
		margin-top: var(--status-bar-height);
		height: 100vh;
	}
</style>
